package com.yonyou.pmclouds.safetypatrol.process;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.safetypatrol.entity.SafetypatrolVO;
import com.yonyou.pmclouds.safetypatrol.mapper.SafetypatrolMapper;

/**
 * @author 徐老板
 * @date 2020/4/17   10:37
 */

public class SafetypatrolUpdateCheckProcess implements SingleProcessor<SafetypatrolVO> {

    private SafetypatrolMapper safetypatrolMapper;

    public SafetypatrolUpdateCheckProcess(SafetypatrolMapper safetypatrolMapper) {
        this.safetypatrolMapper = safetypatrolMapper;
    }
    //修改这里进行两个判断 一个是有没有搜到值 一个是一个企业下的安全标准有没有重复
    @Override
    public void process(SafetypatrolVO vo, SafetypatrolVO orig) throws BusinessException {
        if (vo!=null){
        Integer checkRepeat = safetypatrolMapper.checkRepeat(vo);
        if (checkRepeat!=null && checkRepeat>0){
            throw new BusinessException("该安全标准重复, BuziExCodeConst.CODE_NAME_BEEN_USED");
            }
        }
    }
}
